<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:p="http://primefaces.prime.com.tr/ui">

    <body>

        <ui:composition template="./../../Template/generalTemplate.xhtml">

            <ui:define name="content">

                <h:form id="form">
                    <f:view beforePhase="#{editClientManagedBean.customerInit}">
                        <p:panel id="editCustomer" header="Edit Customer" style="height:495px;">
                            <p:wizard showStepStatus="false"  widgetVar="wiz" style="height:450px;" flowListener="#{editForecastTableManagedBean.onFlowProcess}">
                                <p:tab title="1" id="companyDetail">
                                    <div style="margin-top:45px;margin-left:330px;height:355px;">
                                        <h:panelGrid id="grid" columns="3">
                                            <h:outputText value="Company Name:" style="font-weight: bold;" />
                                            <p:inputText  id="companyName" required="true" requiredMessage="Company Name Can not be Blank" value="#{editClientManagedBean.customer.name}" />
                                            <p:message for="companyName" />

                                            <h:outputText value="Email:" style="font-weight: bold;" />
                                            <p:inputText  id="email" required="true" requiredMessage="Company email Can not be Blank" value="#{editClientManagedBean.customer.email}" />
                                            <p:message for="email" />

                                            <h:outputText value="Contact Person:" style="font-weight: bold;"/>
                                            <h:selectOneMenu id="title" value="#{editClientManagedBean.customer.contactPersonTitle}">
                                                <f:selectItem itemLabel="Please select..." noSelectionOption="true"/>
                                                <f:selectItem itemValue="Mr" itemLabel="Mr"/>
                                                <f:selectItem itemValue="Mrs" itemLabel="Mrs"/>
                                                <f:selectItem itemValue="Ms" itemLabel="Ms"/>
                                            </h:selectOneMenu>
                                            <p:message  for="title" />


                                            <h:outputText value=""/>
                                            <p:inputText id="contactPerson" required="true" requiredMessage="Contact Person Name Can not be Blank" value="#{editClientManagedBean.customer.contactPersonName}"/>
                                            <p:message for="contactPerson"/>


                                            <h:outputText value="Contact Number:" style="font-weight: bold;"/>
                                            <p:inputMask id="contactNumber" required="true" requiredMessage="Contact Number Can not be Blank" value="#{editClientManagedBean.customer.contactNumber}" mask="(99)99999999"/>
                                            <p:message for="contactNumber"/>

                                            <h:outputText value="Company Address:" style="font-weight: bold;"/>
                                            <p:inputText id="companyStreetName" required="true" requiredMessage="Company Address Street Name Can not be Blank" value="#{editClientManagedBean.customer.address.streetName}"/>
                                            <p:watermark value="street name" for="companyStreetName"/>
                                            <p:message for="companyStreetName"  />

                                            <p:inputText id="companyCity" required="true" requiredMessage="Company Address City Can not be Blank" value="#{editClientManagedBean.customer.address.city}"/>
                                            <p:watermark value="city name" for="companyCity"/>
                                            <p:message for="companyCity"  />

                                            <p:inputText id="companyPostCode" required="true" requiredMessage="Company Post Code Can not be Blank" value="#{editClientManagedBean.customer.address.postCode}"/>
                                            <p:watermark value="post code" for="companyPostCode"/>
                                            <p:message for="companyPostCode"  />
                                        </h:panelGrid>

                                    </div>
                                </p:tab>

                                <p:tab title="2" id="addressDetail">
                                    <p:growl id="growl" showDetail="true" />
                                    <div style="margin-top:20px;margin-left:35px;margin-bottom:120px;postion:relative;float:left;width:900px;height:260px;">
                                        <h:outputText value="Billing Addresses" style="font-weight:bold;"/>
                                        <p:dataTable  id="billing" value="#{editClientManagedBean.customer.billingAddresses}" var="bl" dynamic="true" emptyMessage="No Billing Address yet" paginator="true" rows="3">
                                            <p:column headerText="Street Name">
                                                #{bl.streetName}
                                            </p:column>
                                            <p:column headerText="City">
                                                #{bl.city}
                                            </p:column>
                                            <p:column headerText="Post Code">
                                                #{bl.postCode}
                                            </p:column>
                                            <p:column >
                                                <h:commandLink value ="Delete" immediate="true"  action="#{editClientManagedBean.deleteBilling(bl)}" />
                                            </p:column>
                                        </p:dataTable>
                                    </div>
                                    <div style="position:absolute;top:430px;left:260px;">

                                        <p:panel id="add" header="Add Address" toggleable="true" style="width:900px;">
                                            <table>

                                                <td><h:outputText value="Street Name"/></td>
                                                <td><h:inputText  value="#{editClientManagedBean.address.streetName}" />    
                                                </td>
                                                <td><h:outputText value = "City"/></td>
                                                <td><h:inputText  value="#{editClientManagedBean.address.city}"  /> 
                                                </td>
                                                <td><h:outputText value="Post Code"/></td>
                                                <td><h:inputText  value="#{editClientManagedBean.address.postCode}" />    
                                                </td>
                                                <td><p:commandButton value="Add to Billing Address" actionListener="#{editClientManagedBean.addToBilling}" update="billing add growl" ajax="true"   /></td>
                                            </table>
                                        </p:panel>
                                    </div>
                                </p:tab>

                                <p:tab title="3" id="addressDetail2">
                                    <p:growl id="growl2" showDetail="true" />
                                    <div style="postion:relative;margin-top:20px;margin-left:35px;margin-bottom:120px;padding:5px;width:900px;height:260px;">
                                        <h:outputText value="Shipping Addresses" style="font-weight:bold;"/>
                                        <p:dataTable  id="shipping" value="#{editClientManagedBean.customer.shippingAddresses}" var="sl" dynamic="true" emptyMessage="No Shipping Address yet" paginator="true" rows="3">
                                            <p:column headerText="Street Name">
                                                #{sl.streetName}
                                            </p:column>
                                            <p:column headerText="City">
                                                #{sl.city}
                                            </p:column>
                                            <p:column headerText="Post Code">
                                                #{sl.postCode}
                                            </p:column>
                                            <p:column >
                                                <h:commandLink value ="Delete"  action="#{editClientManagedBean.deleteShipping(sl)}"/>
                                            </p:column>

                                        </p:dataTable>

                                    </div>
                                    <div style="position:absolute;top:430px;left:260px;">

                                        <p:panel id="add2" header="Add Address" toggleable="true" style="width:900px;">
                                            <table>

                                                <td><h:outputText value="Street Name"/></td>
                                                <td><h:inputText  value="#{editClientManagedBean.address.streetName}" />    
                                                </td>
                                                <td><h:outputText value = "City"/></td>
                                                <td><h:inputText value="#{editClientManagedBean.address.city}"  /> 
                                                </td>
                                                <td><h:outputText value="Post Code"/></td>
                                                <td><h:inputText value="#{editClientManagedBean.address.postCode}" />    
                                                </td>
                                            <td><p:commandButton value="Add to Shipping Address" actionListener="#{editClientManagedBean.addToShipping}" update="shipping add2 growl2" ajax="true"   /></td>
                                            </table>
                                        </p:panel>
                                    </div>
                                    <div style="position:absolute;top:540px;left:1000px;">
                                        <p:commandButton value="Save"  ajax="false" update="growl" immediate="true" actionListener="#{editClientManagedBean.customerSaveChanges}" />
                                        <p:commandButton value="Return"  ajax="false" actionListener="#{editClientManagedBean.goBack}" />
                                    </div>
                                </p:tab>

                            </p:wizard>
                        </p:panel>
                    </f:view>
                </h:form>

            </ui:define>

        </ui:composition>

    </body>
</html>

